#ifndef PROGRAM_DATASTRUCT_CHAINHASH_H_
#define PROGRAM_DATASTRUCT_CHAINHASH_H_

namespace hashtable{

class ListElmt
{
public:
    ListElmt(int key, int data);
public:
    void SetKey(int k);
    void SetData(int d);
    void SetPre(ListElmt* p);
    void SetNext(ListElmt* n);

    int GetKey();
    int GetData();
    ListElmt* GetPre();
    ListElmt* GetNext();
private:
    int m_data;
    int m_key;
    ListElmt* m_pre;
    ListElmt* m_next;
};

class DoubleList
{
public:
    DoubleList();
    ~DoubleList();
public:
    ListElmt* ListHead();
    ListElmt* ListTail();
    int GetListSize();

    ListElmt* ListDel(ListElmt* e);
    void ListInsert(ListElmt* e);
    void ListInsert(ListElmt* e, ListElmt* i);
private:
    ListElmt* m_head;
    ListElmt* m_tail;
    int m_size;
};

class ChainHashTable
{
public:
    ChainHashTable(int b);
public:
    int GetHashSize();
    void ChtblInsert(int k, int d);
    void ChtblDel(int k);
    bool ChtblLookup(int k, int& d);
private:
    int hashbuckets(int k);
private:
    DoubleList* m_data;
    int m_buckets;
    int m_size;
};

}
#endif // PROGRAM_DATASTRUCT_CHAINHASH_H_
